package com.leon.controller;

import com.leon.apis.CommentControllerApi;
import com.leon.dtos.CommentDto;
import com.leon.dtos.CommentLikeDto;
import com.leon.dtos.CommentSaveDto;
import com.leon.dtos.ResponseResult;
import com.leon.service.impl.CommentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @program: CommentTest
 * @author: Leon
 * @date: 2021-03-21 15:26
 **/
@RestController
@RequestMapping("/api/v1/comment")
public class CommentController implements CommentControllerApi {

    @Autowired
    private CommentServiceImpl commentServiceImpl;

    @PostMapping("/save")
    @Override
    // 保存评论数据
    public ResponseResult saveComment(@RequestBody CommentSaveDto dto) {
        return commentServiceImpl.saveComment(dto);
    }


    @PostMapping("/like")
    @Override
    // 对评论进行点赞
    public ResponseResult like(@RequestBody CommentLikeDto dto) {
        return commentServiceImpl.like(dto);
    }


    @PostMapping("/load")
    @Override
    // 查询某篇文章下的评论信息（分页查询）
    public ResponseResult findByArticleId(@RequestBody CommentDto dto) {
        return commentServiceImpl.findByArticleId(dto);
    }

}
